﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Net.Mail;
using System.Web.Security;
using System.IO;
using System.Data.SqlClient;

/// <summary>
/// Summary description for AddFlightBAL
/// </summary>
public class AddFlightBAL
{
    public AddFlightBAL()
    {

    }

    public bool AddFlight(String AirPlaneName, String ScheduleName, DateTime DepartTime, int AvailBussinessSeat, int AvailFirstSeat, int AvailClubSeat, String FlightStatus, bool isAllowSmoking)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString);
        con.Open();
        String sqlCommand = "INSERT INTO Airline_Flight VALUES(" + AirPlaneName + "," + ScheduleName + ",'" + DepartTime.ToString() + "'," + AvailBussinessSeat.ToString() + "," + AvailFirstSeat.ToString() + "," + AvailClubSeat.ToString() + ",'" + FlightStatus + "'," + Convert.ToInt32(isAllowSmoking) + ")";
        bool flag = false;
        try
        {
            SqlCommand com = new SqlCommand(sqlCommand, con);
            int rows = com.ExecuteNonQuery();
            if (rows > 0)
            {
                flag = true;
            }
        }
        catch (Exception e)
        {
            string x = e.Message;
        }
        finally
        {
            con.Close();
        }
        return flag;
    }
}
